package server;

/**
 * @author songyi
 * @date 2020/6/28 0028 11:29
 * @description HTTP协议工具类，主要提供响应头信息
 */
public class HttpProtocoUtil {

    // 响应200状态码，请求信息
    public static String getHeader200(long contentLength) {
        return "HTTP/1.1 200 OK \n" +
                "Content-Type: text/html;charset=utf-8 \n" +
                "Content-Length: " + contentLength + "\n" +
                "\r\n";
    }

    // 响应404状态码，请求信息
    public static String getHeader404() {
        String str404 = "<h1>404 not found</h1>";
        return "HTTP/1.1 404 not found \n" +
                "Content-Type: text/html;charset=utf-8 \n" +
                "Content-Length: " + str404.getBytes().length + "\n" +
                "\r\n" + str404;
    }
}
